import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [{ 
        path: '/',
        name: 'layout',
        component: () =>
            import ('@/views/Layout'),
        children: [{ 
                path: '',
                name: 'home',
                component: () =>
                    import ('@/views/Home')
            },
            { 
                path: 'wenda',
                name: 'wenda',
                component: () =>
                    import ('@/views/Wenda')
            },
            { 
                path: 'video',
                name: 'video',
                component: () =>
                    import ('@/views/Video')
            },
            { 
                path: 'my',
                name: 'my',
                component: () =>
                    import ('@/views/My')
            }
        ]
    },
    { 
        path: '/login',
        name: 'login',
        component: () =>
            import ('@/views/Login')
    },
    { 
        path: '/search',
        name: 'search',
        component: () =>
            import ('@/views/Search')
    },
    { 
        path: '/article/:articleId', //动态路由
        name: 'article',
        props: true, //开启props传参,把路由参数映射到组件props中
        component: () =>
            import ('@/views/Article')
    },
    { 
        path: '/user/profile',
        name: 'user-profile',
        component: () =>
            import ('@/views/User-Profile')
    },
]

const router = new VueRouter({
    routes
})

export default router